package com.aaa.system.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @program: qy165-springboot03
 * @description:
 * @author: 闫克起2
 * @create: 2023-06-19 09:01
 **/
@Configuration //表示类似与配置文件
public class SwaggerConfig {

    @Bean //加在方法上，表示吧方法的返回结果交于spring容器来管理该对象. 里面封装了接口文档的信息，
    public Docket docket(){
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .groupName("qy165")
                .apiInfo(getInfo())
                .select()
                //只为com.aaa.controller包下的类生成接口文档
                .apis(RequestHandlerSelectors.basePackage("com.aaa.system.controller"))
                .build();
        return docket;
    }

    private ApiInfo getInfo(){
        Contact DEFAULT_CONTACT = new Contact("杨凯", "http://www.jd.com", "110@qq.com");
        ApiInfo apiInfo= new ApiInfo("员工管理系统API文档", "员工管理系统API文档",
                "1.5", "localhost:8081/doc.html", DEFAULT_CONTACT, "AAA志远网络有限公司", "http://www.aaa.com");
        return apiInfo;
    }
}
